package com.xiaoge.libraryuse.recycler;

import android.app.Activity;
import android.content.Context;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;
import com.xiaoge.basedevlibrary.utils.StringUtils;
import com.xiaoge.libraryuse.R;

/**
 * Created by guoyzh on 2017-8-8 0008.
 */

public class MeiZiViewHolder extends BaseViewHolder<HttpImageBean.ResultsBean> {
    private ImageView mIv;
    private TextView mTv_who;
    private Context mCtx;


    public MeiZiViewHolder(ViewGroup parent, Activity activity) {
        super(parent, R.layout.recycler_item);
        mCtx = activity;
        mIv = $(R.id.image);
        mTv_who = $(R.id.who);
    }

    @Override
    public void setData(final HttpImageBean.ResultsBean bean) {
        // Log.i("ViewHolder", "position" + getDataPosition());
        // 地址是否为空
        if (!StringUtils.isEmpty(bean.getUrl())) {
//            ImageUtils.getInstance().load(mIv, bean.getUrl());
            Glide.with(mCtx)
                    .load(bean.getUrl())
                    .into(mIv);
        }
        mTv_who.setText(bean.getPublishedAt());
    }
}
